package com.xie.smfs.effect;

import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectCategory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

/**
 * 鬼敲门效果 - 标记玩家为敲门鬼的攻击目标
 */
public class GhostKnockEffect extends StatusEffect {
    public GhostKnockEffect() {
        super(StatusEffectCategory.HARMFUL, 0x2a3b4c); // 深蓝色
    }

    @Override
    public void applyUpdateEffect(LivingEntity entity, int amplifier) {
        // 效果持续期间给予玩家视觉提示
        if (entity instanceof PlayerEntity player && !player.getWorld().isClient) {
            if (entity.getWorld().getTime() % 20 == 0) { // 每20tick提示一次
                player.sendMessage(Text.translatable("effect.smfs.ghost_knock.warning").formatted(Formatting.RED), true);
            }
        }
    }

    @Override
    public boolean canApplyUpdateEffect(int duration, int amplifier) {
        // 每20tick触发一次更新
        return duration % 20 == 0;
    }

    @Override
    public String getTranslationKey() {
        return "effect.smfs.ghost_knock";
    }
}